package impl

import (
	model2 "gf-xb-api/cwt/filter/model"

	"github.com/gogf/gf/v2/database/gdb"
)

type IsNullRuleParser[T any] struct {
	Op        string
	FieldName string
	Rule      *model2.FilterRule[T]
}

func (p *IsNullRuleParser[T]) Parse(op string, fieldName string, rule *model2.FilterRule[T], m *gdb.Model) *gdb.WhereBuilder {

	if op == model2.AndOperator {
		return m.Builder().WhereNull(fieldName)
	}

	return m.Builder().WhereOrNull(fieldName)
}
